﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MCSFramework.BLL.CM;
using System.Data;
using MCSFramework.Common;
using System.IO;

public partial class MatrixTable测试 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {/*
        
        GridView1.DataSource = getDataTable();
        GridView1.DataBind();
        MatrixTable.GridViewMatric(GridView1);
        MatrixTable.GridViewMergSampeValueRow(GridView1, 0);

        */

        //CM_ClientBLL bll = new CM_ClientBLL();
        //DataTable tb = bll.GetFnaTable(60, 1, 0, 0, 0, 0);
        //GridView1.AllowPaging = true;
        //GridView1.PageSize = 10;
        //GridView1.DataSource = tb;
        //GridView1.DataBind();
        
        //MatrixTable.GridViewMatric(GridView1);
        //MatrixTable.GridViewMergSampeValueRow(GridView1, 0);
        //MatrixTable.GridViewMergSampeValueRow(GridView1, 1);
        //MatrixTable.GridViewMergSampeValueRow(GridView1, 2);
    }

    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        this.GridView1.PageIndex = e.NewPageIndex;
        this.GridView1.BottomPagerRow.Visible = false;
    }


    protected void btnFormat_Click(object sender, EventArgs e)
    {        
        GridViewToXML.ToXml(GridView1, Server.MapPath("test.xml"));
    }

    protected void btnNopi_Click(object sender, EventArgs e)
    {
        CM_ClientBLL bll = new CM_ClientBLL();
        DataTable tb = bll.GetFnaTable(60, 1, 0, 0, 0, 0);
        GridView1.AllowPaging = false;
        GridView1.DataSource = tb;
        GridView1.DataBind();
        
        MatrixTable.GridViewMatric(GridView1);
        MatrixTable.GridViewMergSampeValueRow(GridView1, 0);
        MatrixTable.GridViewMergSampeValueRow(GridView1, 1);
        MatrixTable.GridViewMergSampeValueRow(GridView1, 2);

        NPOIToExcel.OptimizaToExcel(GridView1, Server.MapPath("test.xlsx"));

        GridView1.AllowPaging = true;
        GridView1.PageSize = 50;
        GridView1.DataSource = tb;
        GridView1.DataBind();
        MatrixTable.GridViewMatric(GridView1);
        MatrixTable.GridViewMergSampeValueRow(GridView1, 0);
        MatrixTable.GridViewMergSampeValueRow(GridView1, 1);
        MatrixTable.GridViewMergSampeValueRow(GridView1, 2);
    }


    private DataTable getDataTable()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("部");
        dt.Columns.Add("作业区");
        dt.Columns.Add("活跃→分销商");
        dt.Columns.Add("活跃→经销商");

        DataRow dr;

        dr = dt.NewRow();
        dr[0] = "";
        dr[1] = "";
        dr[2] = "0";
        dr[3] = "60";
        dt.Rows.Add(dr);

        dr = dt.NewRow();
        dr[0] = "营业二部";
        dr[1] = "河南区";
        dr[2] = "83";
        dr[3] = "45";
        dt.Rows.Add(dr);

        dr = dt.NewRow();
        dr[0] = "营业二部";
        dr[1] = "湖北区";
        dr[2] = "28";
        dr[3] = "26";
        dt.Rows.Add(dr);

        dr = dt.NewRow();
        dr[0] = "营业三部";
        dr[1] = "安徽区";
        dr[2] = "17";
        dr[3] = "27";
        dt.Rows.Add(dr);

        dr = dt.NewRow();
        dr[0] = "营业三部";
        dr[1] = "山东区";
        dr[2] = "49";
        dr[3] = "38";
        dt.Rows.Add(dr);

        return dt;
    }
}
